<?php
session_start(); 
include_once "config.php";
include_once "connect.php";

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>AP3-SP-les phoques du desert</title>

<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="verification.js"></script>	
<script type="text/javascript" src="menu.js"></script>	
<script type="text/javascript" src="jquery.js"></script>

</head>

<body onLoad="display_c()">
	
	<div id="all">
		<div id="header">		
			<h1>Les Phoques Du Desert<h1>
			<?php include_once "login.php"; ?>
		</div>
		
		<div id="content">
			<?php
			$id_type=1;
			$session=0;
			$log=0;
			$log2=0;
			$pseudo="";
			$i=0;
			
			if(isset($_SESSION["user"])){
				$log2=1;
				$pseudo=$_SESSION["user"];
			}
			
			$post=mysql_query("select * from AP3_SP_user");
			
			if($log2==1){
				$post2=mysql_query("select id_type from AP3_SP_user where pseudo=\"".$pseudo."\"") or die(mysql_error());
				$p2=mysql_fetch_assoc($post2);
				foreach($p2 as $resu){}
			}	
			
			$categorie=mysql_query("select libelle_categorie from AP3_SP_categorie order by id_categorie");
			
			echo "<ul>";
			
			while($t=mysql_fetch_assoc($categorie))	{
				echo "<span class='navigation' id='titre_".$t["libelle_categorie"]."' onClick=menu('sous_".$i."')>";
					
					if($t["libelle_categorie"]=="Informations générales"){
						echo "<li>".$t["libelle_categorie"] ."</li>";	
						
						$res=mysql_query("Select * from AP3_SP_rubrique as R
											join	AP3_SP_categorie as C  ON R.id_categorie=C.id_categorie
											where libelle_categorie='".$t["libelle_categorie"]."' ");
									
						echo "<ul class='ulsubMenu'>";
						echo "<div id='sous_".$i."' class='subMenu'>";
						
						while($row=mysql_fetch_assoc($res)){
							echo "<li><a href='categorie.php?id=".$row["id_rubrique"]."'>".$row["libelle_rubrique"] ."</a></li>";
						}
						
						echo "</div>";
						echo "</ul>";
					}
					
					if($t["libelle_categorie"]!="Informations générales"){
						if(isset($_SESSION["user"]))
							$log=1;
							
						if($t["libelle_categorie"]!="Admin" && $log==1){
							echo "<li>".$t["libelle_categorie"] ."</li>";
							
							$res=mysql_query("Select * from AP3_SP_rubrique as R
													join	AP3_SP_categorie as C  ON R.id_categorie=C.id_categorie
													where libelle_categorie='".$t["libelle_categorie"]."' ");
											
							echo "<ul class='ulsubMenu'>";
							echo "<div id='sous_".$i."' class='subMenu'>";
							
							while($row=mysql_fetch_assoc($res)){
								echo "<li><a href='categorie.php?id=".$row["id_rubrique"]."'>".$row["libelle_rubrique"] ."</a></li>";
							}
							
							echo "</div>";
							echo "</ul>";
						}
						
						elseif($t["libelle_categorie"]=="Admin" && $log==1){
							if($resu==3){
								echo "<li>".$t["libelle_categorie"] ."</li>";
								
								$res=mysql_query("Select * from AP3_SP_rubrique as R
														join	AP3_SP_categorie as C  ON R.id_categorie=C.id_categorie
														where libelle_categorie='".$t["libelle_categorie"]."' ");
												
								echo "<ul class='ulsubMenu'>";
								echo "<div id='sous_".$i."' class='subMenu'>";
								
								while($row=mysql_fetch_assoc($res)){
									echo "<li><a href='admin.php?id=".$row["id_rubrique"]."'>".$row["libelle_rubrique"] ."</a></li>";
								}
								
								echo "</div>";
								echo "</ul>";
							}
						}
					}
					
				$i++;	
				echo "</span>";
			}?>
			
			</ul>
		</div>
		
		<div id="footer">
			<div id="ct"></div>
			
			<div class="droit">
				<marquee>Made by Les Phoques Du Désert &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bienvenue :)       </marquee>
			</div>
			
		</div>
		
		
	</div>
</body>
</html>